package com.zym.entity;

import com.zym.Valid.AddGroup;
import com.zym.Valid.UpdateGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
@Data
@Accessors(chain = true)
public class Users {
    @NotNull(message = "ID不能为空",groups = {UpdateGroup.class})
    @Null(message = "ID必须为空",groups = {AddGroup.class})
    private Long id;
    @NotBlank(message = "姓名不允许为空",groups = {UpdateGroup.class,AddGroup.class})
    @Length(min = 2,max = 10,message = "姓名长度错误，长度长度2-10！")
    private String name;

    @NotNull(message = "年龄不能为空",groups = {UpdateGroup.class,AddGroup.class})
    @Min(value = 18,message = "年齡最小不能小于18",groups = {UpdateGroup.class,AddGroup.class})
    private int age;

    @NotBlank(message = "地址不能为空")
    private String address;

    @Pattern(regexp = "^1(3[0-9]|5[012356789]|7[1235678]|8[0-9])\\d{8}$", message ="手机号格式错误")
    private String phone;

    @Email(message = "邮箱格式错误")
    private String email;

    //省略get、set方法
}

